﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNLTHD_GoogleMapAPI_DAO;
using CNLTHD_GoogleMapAPI_DTO;
using CNLTHD_GoogleMapAPI.UserControl;

namespace CNLTHD_GoogleMapAPI
{
    public partial class TimKiem : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(TimKiem));
			if (!IsPostBack)
			{
				string noiDungTimKiem = Request.QueryString["txtTimKiem"];

				if ( noiDungTimKiem == null)
				{
					return;
				}
				txtTimKiem.Text = noiDungTimKiem;
				Literal1.Text = @"$(document).ready(function() {
					btnGetListTK_Click();
  // Handler for .ready() called.
});";
			}
		
        }
        [AjaxPro.AjaxMethod]
        public bool themDD(double kinhDo, double viDo, int maLoaidd, String tenDiaDiem, String ghiChu)
        {
            NguoiDung nd = (NguoiDung)Session["NguoiDung"];
            return DiaDiemDAO.ThemDiaDiem(kinhDo, viDo, nd.MaNguoiDung, maLoaidd, tenDiaDiem, ghiChu);
        }

        [AjaxPro.AjaxMethod]
        public bool checkDangNhap()
        {
            return Session["NguoiDung"] != null;
        }

        [AjaxPro.AjaxMethod]
        public Object[] getDSLoaiDD()
        {
            List<LoaiDiaDiem> list = LoaiDiaDiemDAO.LayDaySachLoaiDiaDiem();
            Object[] DD = new Object[list.Count * 2 + 1];
            DD[0] = list.Count;
            for (int i = 1; i <= list.Count; i++)
            {
                DD[i] = list[i - 1].MaLoaiDiaDiem;
                DD[list.Count + i] = list[i - 1].TenLoaiDiaDiem;
            }

            return DD;
        }
    }
}